package com.tac.controller.mes;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.mes.JobAssembly;
import com.tac.service.mes.JobAssemblyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/jobAssembly")
@CrossOrigin
@Api(tags = "制造执行MES--作业装配接口")
public class JobAssemblyController {

    @Autowired
    private JobAssemblyService jobAssemblyService;

    @GetMapping("/getList")
    @ApiOperation("作业装配查询")
    public Result<PageInfo<JobAssembly>> getList(
            @RequestParam(required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String jobName,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTimeStart,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTimeEnd,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTimeStart,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTimeEnd) {

        return jobAssemblyService.getList(pageNum, pageSize, jobName, startTimeStart, startTimeEnd, endTimeStart, endTimeEnd);
    }

    @PostMapping("/save")
    @ApiOperation("作业装配添加")
    public Result save(@RequestBody JobAssembly jobAssembly) {
        return jobAssemblyService.save(jobAssembly);
    }
    @ApiOperation("作业装配删除")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody List<Integer> ids) {
        return jobAssemblyService.remove(ids);
    }
    @ApiOperation("作业装配更新")
    @PutMapping("/update")
    public Result update(@RequestBody JobAssembly jobAssembly) {
        return jobAssemblyService.update(jobAssembly);
    }
}
